#include "instructions/loads/aload.h"

namespace jvm {
namespace instructions {

void aLoad(std::shared_ptr<rtda::Frame> frame, uint index) {
    auto ref = frame->getLocalVars().getRef(index);
    frame->getOperandStack()->pushRef(ref);
}

void ALOAD::execute(std::shared_ptr<rtda::Frame> frame) {
    aLoad(frame, _index);
}

void ALOAD_0::execute(std::shared_ptr<rtda::Frame> frame) {
    aLoad(frame, 0);
}

void ALOAD_1::execute(std::shared_ptr<rtda::Frame> frame) {
    aLoad(frame, 1);
}

void ALOAD_2::execute(std::shared_ptr<rtda::Frame> frame) {
    aLoad(frame, 2);
}

void ALOAD_3::execute(std::shared_ptr<rtda::Frame> frame) {
    aLoad(frame, 3);
}

} // namespace instructions
} // namespace jvm